package main

import (
	"context"
	"log/slog"

	"gitee.com/gousing/logger"
)

func init() {
	logger.SetLevel(slog.LevelDebug)
}
func main() {
	logger.Debug("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	logger.Info("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	logger.Warn("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	logger.Error("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	use()
}
func use() {
	myLog := logger.Use(func(ctx *context.Context, record *slog.Record) error {
		record.AddAttrs(slog.String("k1", "1234567890"))
		return nil
	}, func(ctx *context.Context, record *slog.Record) error {
		if record.Level < slog.LevelError {
			// dont record error
			return nil
		}
		record.AddAttrs(slog.String("error", "record log"))
		return nil
	})
	myLog.Debug("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	myLog.Info("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	myLog.Warn("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
	myLog.Error("hello world", slog.String("name", "gousing"), slog.Int("age", 18))
}
